home *** CD-ROM | disk | FTP | other *** search
- Path: Belgium.EU.net!box!pahint
- From: pahint@eunet.be (Pieter Hintjens)
- Newsgroups: comp.lang.c
- Subject: Re: Universal include fil
- Date: 26 Feb 1996 17:42:08 GMT
- Organization: EUnet Belgium, Leuven, Belgium
- Message-ID: <4gsrdg$hkh@news.Belgium.EU.net>
- References: <4grmre$3uu@gail.ripco.com>
- NNTP-Posting-Host: box.eunet.be
- X-Newsreader: TIN [version 1.2 PL2]
-
- Martin Ambuhl (mambuhl@ripco.com) wrote:
- : pahint@eunet.be (Pieter Hintjens)
- : in <4gnjea$30m@news.Belgium.EU.net> writes:
-
- : >I am working on a project to build a 'Universal Include File'.
-
- : There is no conditional for the following
- : >#include <fcntl.h>
- : even though it is clearly _not_ a standard header.
- : Since the other 9 headers in this group are standard headers,
- : and since fcntl.h is not guaranteed to be present, I suggest
- : a test for the implementation.
-
- Can you suggest a test?
-
- : The failure to include locale.h, iso646.h, wctype.h, and wchar.h is
- : perhaps understandable, since many implementations will not have the
- : last three (Amendment 1) headers and these 4 are of limited use to many
- : programmers. I am a little suprised that this should be true for you as
- : a .be domain programmer.
-
- I'll add locale.h. Hey, I'm a domain .world programmer, I just never
- had use for these guys. Locale.h is useful enough and widespread enough
- to get onto the list.
-
- : However, I find the failure to include the standard headers assert.h,
- : float.h, math.h, setjmp.h, and stddef.h a little hard to understand.
-
- Okay, okay, you convinced me. They're on the list too.
-
- : It is not enough to just #include whatever headers are in some
- : implementation. If your code actually uses any of the stuff associated
- : with non-standard headers, you better supply some definition of how
- : _other_ implementations can see the same code and do the "right" thing.
-
- : Since different implementations will have different definitions of the
- : non-standard `extensions', you will perhaps find this exercise worse
- : than frustrating.
-
- I think the only non-ANSI stuff I use is UNIX-type file handling, since
- it's necessary for sockets. Also, it is widespread if not universal.
-
- : You are missing many other common systems. Check the code for one that
- : is missing (__GCC__) and you will find many of the useful ones that you
- : have omitted.
-
- On problem with gcc (not the product, just the symbol) is that it does
- not say a lot about the header files or libraries. For instance, I'm
- trying to find a clean way to compile on a Sun with gcc. Gcc is using
- the non-ANSI Sun header files and library. What use is __GCC__ for any
- kind of work then?
-
- : >#if (defined (__TURBOC__)) /* Borland Turbo-C uses this */
- : ># include <alloc.h> * name for its include file */
- : >#else
- : ># include <malloc.h>
- : >#endif
-
- : The above is a poor idea. There are several reasons. One is that
- : Borland has long supplied a malloc.h and alloc.h. Check the contents of
- : these. You will find that Borland's malloc.h includes alloc.h itself.
- : Now, if you have included stdlib.h and stddef.h, you will not need
- : malloc.h (or alloc.h) for any of NULL, ptrdiff_t, calloc(), free(),
- : malloc(), or realloc().
-
- Right. I've been fooled by an old compiler. Malloc/calloc are going
- out. I think.
-
- : If you code has a prayer of portability you should not want -- and with
- : adequate care or the right tools you will not need -- any of headcheck,
- : heapfillfree, heapcheckfree, coreleft, _memavl() heapchecknode,
- : heapwalk,
- : or the abominatitions of the far versions [far*(), _f*()], huge versions
- : [h*()] or near versions [_n*()] of the various standard and non-standard
- : functions here.
-
- What're all these things? Never heard of them. Hey, portability is
- finally the result of persistent porting, no more or less.
-
- : Nor will you need the struct [far]heapinfo.
-
- Whatdyasay?
-
- : So just
- : #include <stdlib.h>
- : #include <stddef.h>
-
- : And forget the malicious jokes <malloc.h> and <alloc.h>.
-
- Thanks, Martin, for the useful comments.
-
- --
- Pieter A. Hintjens
-